package com.colin.aiyi.dao.ImpxUtils;

import com.colin.aiyi.app.Constant;
import com.colin.aiyi.entity.User;
import com.colin.aiyi.entity.response.UserInfoResponse;

import org.xutils.http.RequestParams;

/**
 * Created by hl on 2017/6/9.
 */

public class ImpGetUserInfo extends AbsServicexUtils{
    User user;
    @Override
    public void onSuccess(String result) {
        super.onSuccess(result);
        UserInfoResponse userInfoResponse=gson.fromJson(result,UserInfoResponse.class);
        userInfoResponse.getData().setAccessToken(user.getAccessToken());
//        userInfoResponse.getData().setVip(user.isVip());
        userInfoResponse.getData().setUserId(user.getUserId());
        sendMsgToView(userInfoResponse);
    }

    @Override
    public <V> void getObject(V v) {
        super.getObject(v);
           user= (User) v;
            RequestParams parems=new RequestParams(Constant.getUserInfo);
            parems.addBodyParameter("accessToken",user.getAccessToken());
            parems.addBodyParameter("clientId",Constant.CLIENT_ID);
            parems.addBodyParameter("clientSecret",Constant.CLIENT_SECRET);
            sendToServer(parems);
        }
    }
